"""
字符串使用
"""
# 格式化  格式：%[+或-] [0] [m] [.n] 格式字符
# a = 12
# b = 12345678.1234567
# s = 'I love python!'
# print('a = %05d' % a)
# print('b = %8.3f' % b)
# print('%17s' % s)
# print('%-17.6s' % s)
#
# # format()函数
# name = "黄峰峰"
# age = 23
# sex = "女"
# introduce = "我叫{}，我今年{}岁了，我的性别是{}"
# introduce_01 = "我叫{2}，我今年{0}岁了，我的性别是{1}"
# print(introduce.format(name,age,sex))
# print(introduce_01.format(name,age,sex))
#
# # find()
# str1 = "我在上课，上的班级是24计算机z2，有人睡觉，有人聊天，我很不开心！！"
# str2 = "睡觉"
# print(str1.find(str2))
# print(str1.find("-")) # 没有就返回-1
# if str1.find(str2) == -1:
#     print("目标字符串str1没有查到'{}'".format(str2))
# else:
#     print("查找成功！！字符串：'{}'包含字符串：'{}'，第一次出现的下标为：'{}'".format(str1,str2,str1.find(str2)))
#
# #split()
# #默认分隔符
# str3 = "hello world"
# print(str3.split())
# #指定分隔符
# str4 = "hello -world"
# print(str4.split("-"))
# print(str4.split("~"))
# #指定最大分割次数
# str5 = "apple,banana,cherry,orange"
# fruits = str5.split(",")
# fruits_01 = str5.split(",",2)
# print(fruits)
# print(fruits_01)
#
# #join()
# print("-".join(str3))
#
# # 将字符串"Rain falls   on  field  and     tree."中的多余空格删除（有连续的空格保留一个，每个单词之间只能留一个空格）
# str6 = "Rain falls   on  field  and     tree."
# mid = str6.split()
# print(mid)
# res = " ".join(mid)
# print(res)
#
# #replace()
# str7 = "abc def abc gh abc"
# print(str7.replace("abc","123"))
# print(str7.replace("abc","123",2))

# strip()
# str8 = "   aaabbb123   "
# print(str8)
# print(str8.strip())
# print(str8.strip(" a1"))

# lower()
# upper()
str9 = "agdgdasg---GHEGFGEWGHAHRG"
# print(str9.lower())
# print(str9.upper())
# isalnum()
str10 = "gdsagd123456"
str11 = "123456"
str12 = "gdsagd"
print(str9.isalnum())
print(str10.isalnum())
print(str11.isalnum())
print(str12.isalnum())
